from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By


def getHtml(page: 1):
    return "https://www.toopic.cn/4kbz/?q=--81--.html&page=%s" % page


s = Service("C:\Program Files\Google\Chrome\Application\chromedriver.exe")
driver = webdriver.Chrome(service=s)

if __name__ == "__main__":
    lists = list(range(1))
    print(lists)
    urlList = list()
    driver.get(getHtml(0))
    page = driver.find_element(by=By.CSS_SELECTOR, value="div.page")
    pageS = page.find_elements(by=By.TAG_NAME, value="a")

    for i in pageS:
        html = i.get_attribute("href")
        print(html)

    # for i in lists:
    #     driver.get(getHtml(i))
    #     div = driver.find_elements(by=By.CSS_SELECTOR, value="div.bd")
    #     for t in div:
    #         img = t.find_element(by=By.TAG_NAME, value="img")
    #         src = img.get_attribute("src")
    #         if src.endswith("png"):
    #             urlList.append(src)
    # print(urlList)
    # driver.close()
